package org.datacoder.geocoding.datastructures.util

import org.datacoder.geocoding.datastructures.geoshapes.*

class GeoIntervalEndPointComparator implements Comparator<GeoInterval> {

    public int compare(GeoInterval gi1, GeoInterval gi2){
        double returnVal
        returnVal = gi1.retrieveMaxDoubleValue() - gi2.retrieveMaxDoubleValue()
        if(returnVal == 0){
            returnVal = gi1.retrieveMinDoubleValue() - gi2.retrieveMinDoubleValue()
            if(returnVal == 0){
                returnVal = gi1.juris.id - gi2.juris.id
            }
        }
        returnVal *= -1
        if(returnVal == 0){
            return 0
        }
        return ((returnVal > 0) ? 1 : -1)
    }

}
